#ifndef XBitmap_First
#define XBitmap_First
#ifdef __GNUG__
#pragma interface
#endif

#include "X11.h"
#include "DevBitmap.h"

class ColorMap;
class XWindowPort;

class XBitmap: public DevBitmap {
friend XWindowPort;
	GC gc;
	XImage *ximage;     // in client
	Pixmap pm;          // in server
	bool inserver : 1;
	bool freedata : 1;

private:
	XImage *CreateImage(Point, u_int, u_short *d= 0, u_short pad= 2);
	XImage *getImage();
	XImage *GetImage()
		{ return (inserver || ximage == 0) ? getImage() : ximage; }
	Pixmap GetPixmap();
	void FreeImage();

public:
	XBitmap(const Point &sz, u_short *data, u_short depth, bool freedata= FALSE, u_short pad= 2);
	XBitmap(const Point &sz, XImage *im);
	XBitmap(XBitmap *xdbm);
	~XBitmap();

	void ReadData(BitmapInfo *bi, IStream &is);
	void SetRow(BitmapInfo *bi, int row, byte *rowdata);
	void SetPixel(u_int x, u_int y, u_long value);
	u_long GetPixel(u_int x, u_int y);
	DevBitmap *MakeCopy();
	void DevMapColors(DevBitmap *src, u_long *map);
	DevBitmap *DevAllocBitmap(const Point &s, u_short d);
	void DevBitBlt(int x, int y, int w, int h, BitBltOp, DevBitmap *s,
									int sx, int sy, u_long val);
};

#endif

